﻿using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using MQTTnet.Server;
using OperationDataBase;

namespace Mqtt.Callback.Handlers
{
    /// <summary>
    /// 收到客户端订阅
    /// </summary>
    public class MqttClientSubscribedTopicHandler : IMqttServerClientSubscribedTopicHandler
    {
        private readonly ILogger _logger;
        public MqttClientSubscribedTopicHandler(ILogger<MqttServer> logger)
        {
            this._logger = logger;
        }

        public Task HandleClientSubscribedTopicAsync(MqttServerClientSubscribedTopicEventArgs eventArgs)
        {
            //var userName = _rule._clientDict[eventArgs.ClientId];
            //_rule.CheckSubscribed(userName, eventArgs.TopicFilter.Topic);
            _logger.LogInformation($"Client: {eventArgs.ClientId} subscribed to {eventArgs.TopicFilter.Topic} topic!");
            return Task.CompletedTask;
        }
    }
}
